package pseudoAssemblerCompiler.twopassassembler.model;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * User: Роман
 * Date: 22.06.12
 * Time: 15:19
 */
public class Utils {

    public static String addrBuild(int aNumberToAppend, int amountOfAppendZero) {
        StringBuilder builder = new StringBuilder();
        String addr = Integer.toHexString(aNumberToAppend);
        for (int i = 0; i < (amountOfAppendZero - addr.length()); i++) {
            builder.append('0');
        }
        builder.append(addr);
        addr = builder.toString();
        builder.delete(0, amountOfAppendZero); //очищаем строку для нового адреса
        return addr;
    }

    public static List<String> getTokens(String s) {
        List<String> tokens = new ArrayList<String>();
        String[] arr = s.split("\\s+");
        for (String str : arr) {
            if(!"".equals(str)) {
                tokens.add(str);
//                System.out.print(str + " ");
            }
        }
        System.out.println();
        return tokens;
    }

}
